package com.hk.servlet.admin;

import com.hk.utils.CharacterEncoding;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: zhe
 * @Date: 2021/6/9 9:22
 * @Statement: 销毁，退出登录
 */
@WebServlet("/admin/destroyLogin")
public class DestroyByLoginServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CharacterEncoding.setCharacterEncoding(req,resp,"UTF-8");
        req.getSession().removeAttribute("admin");
        System.out.println("退出登录");
        PrintWriter out = resp.getWriter();
        out.println(1);
        out.flush();
        out.close();
    }
}
